﻿namespace MetaProperties.Core
{
    using System.Threading;

    /// <summary>
    /// A read-only container of a synchronization context.
    /// </summary>
    public class SynchronizationContextContainer : ISynchronizationContextContainer
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SynchronizationContextContainer"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public SynchronizationContextContainer(SynchronizationContext context)
        {
            this.SynchronizationContext = context;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SynchronizationContextContainer"/> class.
        /// </summary>
        public SynchronizationContextContainer()
        {
            this.SynchronizationContext = SynchronizationContext.Current;
        }

        /// <summary>
        /// Gets the synchronization context.
        /// </summary>
        /// <value>The synchronization context.</value>
        public SynchronizationContext SynchronizationContext 
        { 
            get; 
            private set; 
        }
    }
}